#include "include/render.h"
#include <types.h>
#include <kernel.h>
#include <klibc/stdio.h>
#include <klibc/string.h>
#include "include/env.h"

int 
pork_gui(int x, int y)
{
	env_render(x,y,1);
	
	int x1 = 91;
	int y1 = 10;
	int i = 1;
	
	while(1)
	{			
		char c = getchar();
		
		if(c == '\t')
		{
			i++;
			if(i > 4)
				i = 1;
			env_render(x,y,i);
			x1 = 91 + envs[i].cmd_p * 8;
			y1 = 10;
	
			continue;
		}
		if(c == '\n')
		{
			strcpy(envs[i].cmd, "\0");
			envs[i].cmd_p = 0;
			x1 = 91;
			env_render(x,y,i);
			continue;
		}
		if(c == 0)
			continue;
		else if(x1 < (312))
		{
			envs[i].cmd[envs[i].cmd_p] = c;
			envs[i].cmd_p++;
			render_write_letter(8, c, 0xFFFFFF, x1,y1);
		}
		x1 += 8;
	}
	return 0;
}
